import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
// mobx Provider
import { Provider } from 'mobx-react';

// react 国际化 自定义 Provider

// hash 路由 {BrowserRouter|HashRouter}
import { HashRouter as Router } from 'react-router-dom';

// router render .
import { renderRoutes } from 'react-router-config';
import IntlProviderWrap from './components/IntlProviderWrap';
import * as serviceWorker from './serviceWorker';
// router configs
import routes from './routes';
// mobx store configs
import global from './stores/global';
// mobx 语言设置
import language from './stores/language';

const render = () => {
  const dom = document.getElementById('root');
  ReactDOM.render(
    <Provider global={global} language={language}>
      <IntlProviderWrap>
        <Router>{renderRoutes(routes)}</Router>
      </IntlProviderWrap>
    </Provider>,
    dom
  );
};
render();

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
